﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/25/2009
 * Time: 3:23 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Miming.Model;

namespace Miming.Gui
{
	/// <summary>
	/// Description of AddressForm.
	/// </summary>
	public partial class AddressForm : BaseForm
	{
		public AddressForm() : this(new Address())
		{
			
		}
		
		public AddressForm(Address a)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = a;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			Address a = Model as Address;
			richTextBoxStreet.Text = a.Street1;
			textBoxCity.Text = a.City;
			textBoxState.Text = a.State;
			textBoxZip.Text = a.Zip;
			textBoxCountry.Text = a.Country;
			textBoxNote.Text = a.Note;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			Address a = Model as Address;
			a.Street1 = richTextBoxStreet.Text;
			a.City = textBoxCity.Text;
			a.State = textBoxState.Text;
			a.Zip = textBoxZip.Text;
			a.Country = textBoxCountry.Text;
			a.Note = textBoxNote.Text;
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
